package com.luweijie.sh.mapper;

import com.luweijie.entity.vo.Result;
import com.luweijie.sh.entity.Roles;
import com.luweijie.sh.entity.Users;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author luweijie
 * @since 2020-06-11
 */
@Mapper
public interface UsersMapper extends BaseMapper<Users> {

    @Select("SELECT re.*\n" +
            "FROM  users u ,user_role_relation ur , roles r,  role_resource_relation rr\n" +
            ",resource re \n" +
            "where\n" +
            "u.`name`={name} and u.id=ur.user_id and ur.role_id=r.id and r.id=rr.role_id and rr.resource_id=re.id\n" +
            "\n ")
    Result queryByRole(String name);
}
